package com.juli.school.app.controller.module;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.juli.school.dao.entity.Pub;
import com.juli.school.service.bo.GroupSmsBo;
import com.juli.school.service.bo.RecBo;
import com.juli.school.service.enums.EnumModule;
import com.juli.school.service.impl.GroupSmsService;
import com.juli.school.service.impl.RecService;
import com.juli.school.utils.core.model.CommonResp;
import com.juli.school.utils.core.model.ListResp;
import com.juli.school.utils.core.model.PageResp;

/**
 * 社团活动
 * @author wjp
 * @date 2017年8月30日
 */
@Controller
@RequestMapping("/groupSms")
public class GroupSmsController {
	
	@Resource
	private GroupSmsService groupSmsService;

	@Resource
	RecService recService;
	
	/**
	 * 添加一条社团活动
	 * @return
	 */
	@RequestMapping(value = "add", method = RequestMethod.POST)
	@ResponseBody CommonResp<String> add(GroupSmsBo groupSmsBo) {
		return groupSmsService.add(groupSmsBo);
	}
	
	/**
	 * 删除一条社团活动记录
	 * @return
	 */
	@RequestMapping("delete")
	@ResponseBody CommonResp<String> delete(String snStamp,String stuId) {
		return groupSmsService.delete(snStamp,stuId);
	}
	
	/**
	 * 修改一条社团活动
	 */
	@RequestMapping("update")
	@ResponseBody
	public CommonResp<String> update(GroupSmsBo groupSmsBo) {
		return groupSmsService.update(groupSmsBo);
	}
	
	@RequestMapping("/listPage")
	@ResponseBody CommonResp<PageResp<Pub>> listPage(GroupSmsBo groupSmsBo) {
		return groupSmsService.listPage(groupSmsBo);
	}

	/**
	 * @Description: 增量查询信息列表
	 * @author gaoxiang
	 * @date 2017年9月16日 下午10:27:17
	 */
	@RequestMapping("/list")
	@ResponseBody CommonResp<ListResp<Pub>> list(GroupSmsBo req) {
		return groupSmsService.list(req);
	}
	
	@RequestMapping("/detail")
	@ResponseBody CommonResp<GroupSmsBo> detail(GroupSmsBo groupSmsBo) {
		return groupSmsService.detail(groupSmsBo);
	}
	
	@RequestMapping("detailer")
	public String detailer(GroupSmsBo groupSmsBo,ModelMap model){
		model.put("type", EnumModule.GroupSms);
		CommonResp<List<RecBo>> list = recService.list(groupSmsBo.getSnStamp());
		model.put("recs", list.getData());
		model.put("obj",  groupSmsService.detail(groupSmsBo));
		return "/detail/index";
	}
}
